import {
  Component,
  OnInit,
  ChangeDetectionStrategy,
  ViewChild,
  ElementRef,
  AfterViewInit,
} from "@angular/core";
import { WatermarkService } from "./watermark.service";

@Component({
  selector: "app-watermark",
  templateUrl: "./watermark.component.html",
  styleUrls: ["./watermark.component.less"],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class WaterMarkComponent implements OnInit, AfterViewInit {
  @ViewChild("watermark", { static: false }) watermark!: ElementRef;

  constructor(private waterMarkService: WatermarkService) {}

  ngOnInit(): void {}

  ngAfterViewInit() {
    const watermarkImg = this.waterMarkService.getWatermark();
    this.watermark.nativeElement.style.backgroundImage = `url(${watermarkImg})`;
  }
}
